<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var person = {
            getName: function () {
                return this.name
            }
        }
        var person1 = {
            name: "iverson"
        }
        Function.prototype.myapply = function (context) {
            if (typeof this !== 'function') {
                throw new Error('error')
            }
            var context = context || window
            context.fn = this
            let res
            if (arguments[1]) {
                res = context.fn(arguments[1])
            } else {
                res = context.fn()
            }
            delete context.fn
            return res
        }
        console.log(person.getName.myapply(person1))
    </script>
</body>

</html>